package str

import "unicode"

func shortestCompletingWord(licensePlate string, words []string) string {

	cnt := [26]int{}
	for _, ch := range licensePlate {
		if unicode.IsLetter(ch) {
			cnt[unicode.ToLower(ch)-'a']++
		}
	}

	ans := ""

next:
	for _, word := range words {
		cnt2 := [26]int{}
		for _, ch := range word {
			cnt2[unicode.ToLower(ch)-'a']++
		}

		for i := range cnt {
			if cnt2[i] < cnt[i] {
				continue next // 回到第一层for循环
			}
		}
		if ans == "" || len(word) < len(ans) {
			ans = word
		}
	}

	return ans

}
